import {_decorator, Component, Node, CCInteger, randomRangeInt} from 'cc';

const {ccclass, property} = _decorator;

@ccclass('PipeController')
export class PipeController extends Component {
    /**
     * 速度
     */
    @property(CCInteger)
    speed: number = 50;

    start() {

    }

    update(deltaTime: number) {
        for (let child of this.node.children) {
            child.setPosition(child.position.x - this.speed * deltaTime, child.position.y);
            if (child.position.x < -288) {
                child.setPosition(child.position.x + 288 * 2, 224 + randomRangeInt(-127, 128));
            }
        }
    }
}

